package com.authine.cloudpivot.ext.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.authine.cloudpivot.ext.service.CodeService;
import com.authine.cloudpivot.web.api.controller.base.BaseController;
import com.authine.cloudpivot.web.api.exception.ResultEnum;
import com.authine.cloudpivot.web.api.view.ResponseResult;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

/**
 * @author liujing
 * @version 1.0.0
 * @date : 2021/6/10
 */
@Api(value = "务工库返回人员编号", tags = "01::EXTAPI::务工库返回人员编号")
@RestController
@RequestMapping("/ext/code")
@SuppressWarnings("rawtypes")
public class CodeController extends BaseController {

    @Autowired
    private CodeService codeService;

    @GetMapping("/getCode")
    @ApiOperation(value = "根据组织编码(corpId)务工库返回人员编号", notes = "务工库返回人员编号")
    @ApiImplicitParam(name = "corpId", value = "组织编码", dataType = "string", paramType = "query")
    public ResponseResult getCode(String corpId) {
        validateNotEmpty(corpId);
        int code = codeService.getCode(corpId);
        return getOkResponseResult(code, ResultEnum.SUCCESS.getErrMsg());
    }

    @GetMapping("/updateData")
    @ApiOperation(value = "修复已经导入数据的人员编号;维护编号基础表", notes = "修复已经导入数据的人员编号;维护编号基础表")
    public void updateData() {
        codeService.updateData(getOrganizationFacade());
    }
}
